
package sales.managedbean;

import company.entity.Company;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseEvent;
import sales.entity.SalesInquiry;
import sales.seesion.stateless.SalesInquirySessionBean;


@ManagedBean
@ViewScoped
public class DeleteSalesInquiryManagedBean implements Serializable{
  
    public Long id;  
    @EJB
    SalesInquirySessionBean salesInquirySessionBean;
    private SalesInquiry selectedSalesInquiry;
  

    public DeleteSalesInquiryManagedBean() {
        selectedSalesInquiry = new SalesInquiry();
    }
    
    public void viewInquiry(ActionEvent event) throws IOException{
        SalesInquiry si=(SalesInquiry)event.getComponent().getAttributes().get("viewInquiry");
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("newInquiry", selectedSalesInquiry);
        FacesContext.getCurrentInstance().getExternalContext().redirect("viewSalesInquiry.xhtml");
    }
    

    public List<SalesInquiry> getSalesInquiry() {
        return salesInquirySessionBean.getAllSalesInquiry();
    }

    public void deleteSalesInquiry (ActionEvent event) {
       id=(Long)event.getComponent().getAttributes().get("deleteInquiry");
       salesInquirySessionBean.deleteSalesInquiry(id);
       selectedSalesInquiry = new SalesInquiry();
    }

    public SalesInquiry getSelectedSalesInquiry() {
        return selectedSalesInquiry;
    }

    public void setSelectedSalesInquiry(SalesInquiry selectedSalesInquiry) {
        this.selectedSalesInquiry = selectedSalesInquiry;
    }
       
}
